package com.awz.manage.controller;

import com.awz.manage.dto.ContractCheckDTO;
import com.awz.manage.service.ContractService;
import com.awz.manage.utils.AjaxResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/contract")
@RequiredArgsConstructor
public class ContractController {
	
	private final ContractService contractService;
	
	/**
	 * 查询待处理签约列表
	 *
	 * @param pageNum  页码
	 * @param pageSize 页大小
	 * @param state    签约状态
	 * @param tid      医生团队id
	 * @param oid      机构id
	 * @param sid      服务包id
	 * @param sDate    开始时间
	 * @param eDate    结束时间
	 * @param keyword  关键字
	 **/
	@GetMapping("/pending")
	public AjaxResult pending(@RequestParam(required = false, defaultValue = "1") int pageNum,
	                          @RequestParam(required = false, defaultValue = "10") int pageSize,
	                          @RequestParam(required = false) Integer state,
	                          @RequestParam(required = false) Integer tid,
	                          @RequestParam(required = false) Integer oid,
	                          @RequestParam(required = false) Integer sid,
	                          @RequestParam(required = false) Date sDate,
	                          @RequestParam(required = false) Date eDate,
	                          @RequestParam(required = false) String keyword) {
		return contractService.getPendingContractList(pageNum, pageSize, state, tid, oid, sid, sDate, eDate, keyword);
	}
	
	/**
	 * 查询已处理签约列表
	 *
	 * @param pageNum  页码
	 * @param pageSize 页大小
	 * @param state    签约状态
	 * @param tid      医生团队id
	 * @param oid      机构id
	 * @param sid      服务包id
	 * @param sDate    开始时间
	 * @param eDate    结束时间
	 * @param keyword  关键字
	 **/
	@GetMapping("/processed")
	public AjaxResult processed(@RequestParam(required = false, defaultValue = "1") int pageNum,
	                            @RequestParam(required = false, defaultValue = "10") int pageSize,
	                            @RequestParam(required = false) Integer state,
	                            @RequestParam(required = false) Integer tid,
	                            @RequestParam(required = false) Integer oid,
	                            @RequestParam(required = false) Integer sid,
	                            @RequestParam(required = false) Date sDate,
	                            @RequestParam(required = false) Date eDate,
	                            @RequestParam(required = false) String keyword) {
		return contractService.getProcessedContractList(pageNum, pageSize, state, tid, oid, sid, sDate, eDate, keyword);
	}
	
	@PutMapping
	public AjaxResult check(ContractCheckDTO contractCheckDTO) {
		return contractService.modifyContractState(contractCheckDTO);
	}
	
	
}
